<?php
ob_start();
session_start();
date_default_timezone_set('Asia/Bangkok');
$departid = $_SESSION["departid"];
include "../connect.php";

$strSQL = "SELECT * FROM depart WHERE departid = '$departid' ";
$objQuery = mysql_query($strSQL);
$result = mysql_fetch_array($objQuery);
$deid = $result["de_id"];
header("Content-type:text/html; charset=UTF-8");        
header("Cache-Control: no-store, no-cache, must-revalidate");       
header("Cache-Control: post-check=0, pre-check=0", false);       
 
$q = urldecode($_GET["q"]);
$pagesize = 50; 
$table_db="employee"; 
$find_field="emp_id"; 
$sql = "select * from $table_db  where de_id = '$deid' and locate('$q', $find_field) > 0 order by locate('$q', $find_field), $find_field limit $pagesize";
$results = mysql_query($sql);
while ($row = mysql_fetch_array( $results )) {
	//$id = $row["product_id"]; 
	$name = $row["emp_id"]; 

	$name = str_replace("'", "'", $name);
	
	$display_name = preg_replace("/(" . $q . ")/i", "<b>$1</b>", $name);
	echo "<li onselect=\"this.setText('$name').setValue('$id');\">$display_name</li>";
}
mysql_close();
?>